package com.jiruan.invoicemanagementsystem.dao.Imp;

import com.jiruan.invoicemanagementsystem.dao.IOrderDao;
import com.jiruan.invoicemanagementsystem.pojo.Order;
import com.jiruan.invoicemanagementsystem.util.DBHelper;
import com.jiruan.invoicemanagementsystem.util.PageHelper;

import java.util.ArrayList;

public class IOrderDaoImp implements IOrderDao {

    //返回总条数
    public int getInVoicedCount() {
        String sql ="select count(*) from `order` where invoicingStatus='B' ";
        return DBHelper.currencySqlQuery(sql);
    }


    //返回分页集合
    public ArrayList<Order> getInVoicedList(PageHelper ph){
        String sql ="select *from `order` where invoicingStatus='B' limit ?,?";

        int index=(ph.getPageIndex()-1)*ph.getShowNumber();
//        System.out.println(index);
        return DBHelper.currencySqlQuery(Order.class, sql,index, ph.getShowNumber());

    }


    //接受order id
    public Integer receivenvoice(Integer id){


        String sql="update `order` inner join invoicingrecord i on " +
                "`order`.invoicingRecordId=i.id " +
                "set `order`.invoicingStatus='A',i.status='A' " +
                "where `order`.id=?";

        System.out.println(DBHelper.currencySqlUpdate(sql,id));
        return DBHelper.currencySqlUpdate(sql,id);
    }

}
